
#ifndef _MPxHardwareShader
#define _MPxHardwareShader
//
//-
// ==========================================================================
// Copyright (C) 1995 - 2006 Autodesk, Inc., and/or its licensors.  All 
// rights reserved.
// 
// The coded instructions, statements, computer programs, and/or related 
// material (collectively the "Data") in these files contain unpublished 
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its 
// licensors,  which is protected by U.S. and Canadian federal copyright law 
// and by international treaties.
// 
// The Data may not be disclosed or distributed to third parties or be 
// copied or duplicated, in whole or in part, without the prior written 
// consent of Autodesk.
// 
// The copyright notices in the Software and this entire statement, 
// including the above license grant, this restriction and the following 
// disclaimer, must be included in all copies of the Software, in whole 
// or in part, and all derivative works of the Software, unless such copies 
// or derivative works are solely in the form of machine-executable object 
// code generated by a source language processor.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. 
// AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED 
// WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF 
// NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, 
// OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO 
// EVENT WILL AUTODESK AND/OR ITS LICENSORS BE LIABLE FOR ANY LOST 
// REVENUES, DATA, OR PROFITS, OR SPECIAL, DIRECT, INDIRECT, OR 
// CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS LICENSORS HAS 
// BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES. 
// ==========================================================================
//+
//
// CLASS:    MPxHardwareShader
//
// *****************************************************************************
//
// CLASS DESCRIPTION (MPxHardwareShader)
//
// MPxHardwareShader allows the creation of user-defined hardware shaders.
// A hardware shader allows the plug-in writer to control the on-screen
// display of an object in Maya.
//
// For more information, please see the built-in documentation
// in MPxHardwareShader.cpp.
//
// *****************************************************************************

#if defined __cplusplus

// *****************************************************************************

// INCLUDED HEADER FILES



#include <maya/MStatus.h>
#include <maya/MTypes.h>
#include <maya/MObject.h>
#include <maya/MPxNode.h>
#include <maya/MDrawRequest.h>
#include <maya/M3dView.h>
#include <maya/MDagPath.h>
class MGeometryRequirements;
class MGeometryList;
class MVaryingParameterList;
class MUniformParameterList;
class MRenderProfile;
class MDagModifier;

// *****************************************************************************

// DECLARATIONS


typedef const float floatRegion[2][2];

// *****************************************************************************

// CLASS DECLARATION (MPxHardwareShader)

/// Base class for user defined hardware shaders (OpenMayaUI) (OpenMayaMPx.py)
/**
  Create user defined hardware shaders.
*/
#ifdef _WIN32
#pragma warning(disable: 4522)
#endif // _WIN32

class OPENMAYAUI_EXPORT MPxHardwareShader : public MPxNode
{
public:

	///
	enum TransparencyOptions
	{
		// When set means draw transparent
		///
		kIsTransparent = 0x0001,				
		
		// When set means ignore front back cull
		///
		kNoTransparencyFrontBackCull = 0x0002,	

		// When set means ignor polygon sorting
		///
		kNoTransparencyPolygonSort = 0x0004		
	};

	///
	struct ShaderContext
	{
		// DAG path for the given invocation of the shader
		///
		MDagPath path;

		// Shading engine node for the given invocation of the shader
		///
		MObject shadingEngine;
	};

    ///
	MPxHardwareShader();

    ///
	virtual ~MPxHardwareShader();

	///
	virtual MPxNode::Type type() const;

	// Set the varying parameters used for this shader
	///
	MStatus setVaryingParameters( const MVaryingParameterList& parameters, bool remapCurrentValues = true, MDagModifier* dagModifier = NULL);

	// Set the uniform parameters used for this shader
	///
	MStatus setUniformParameters( const MUniformParameterList& parameters, bool remapCurrentValues = true, MDagModifier* dagModifier = NULL);

	// Methods to overload

	// Override this method to specify this shader's geometry requirements
	///
	virtual MStatus populateRequirements( const MPxHardwareShader::ShaderContext& context, MGeometryRequirements& requirements);

	// Override this method to render geometry
	///
	virtual MStatus render( MGeometryList& iterator);

	// Specifies transparency parameters for the shader.
	// Returning "true" from hasTransparency() superscedes these options.
	//
	///
	virtual unsigned int	transparencyOptions();

	// Query the renderers supported by this shader
	//
	virtual const MRenderProfile& profile();

BEGIN_NO_SCRIPT_SUPPORT:

	// Override this method to specify the list of images
	// that are associated with the given uv set in this shader. 
	// This method is used to determine which texture images 
	// are available in the UV texture editor.
	//
	///	NO SCRIPT SUPPORT
	virtual MStatus	getAvailableImages( const MPxHardwareShader::ShaderContext& context, 
										const MString& uvSetName, 
								        MStringArray& imageNames);

	// Override this method to draw an image of this material.
	// This method allows a shader to override the rendering of
	// the background image used in the UV texture editor.
	// Maya will only use this method if getAvailableImages 
	// returns at least one image name. The imageWidth and 
	// imageHeight parameters should be populated with the 
	// native resolution of the input image to allow pixel 
	// snapping or other resolution dependent operations.
	//
	///	NO SCRIPT SUPPORT
	virtual MStatus	renderImage( const MPxHardwareShader::ShaderContext& context, 
								 const MString& imageName, 
								 floatRegion region,
								 int& imageWidth,
								 int& imageHeight);

END_NO_SCRIPT_SUPPORT:

	// Override this method to draw a image for swatch rendering.
	///
	virtual MStatus renderSwatchImage( MImage & image );

	///
	static  MPxHardwareShader* getHardwareShaderPtr( MObject& object );

	///
	static MString findResource( const MString& name, const MString& shaderPath, MStatus* status = NULL);

	// Attributes inherited from surfaceShader
	/// output color value
	static MObject outColor;
	/// output color red
	static MObject outColorR;
	/// output color green
	static MObject outColorG;
	/// output color blue
	static MObject outColorB;

private:
	static void				initialSetup();
	static const char*	    className();
};

#ifdef _WIN32
#pragma warning(default: 4522)
#endif // _WIN32

// *****************************************************************************
#endif /* __cplusplus */
#endif /* _MPxNode */
